class Solution {
    public int search(int[] nums, int target) {
        //二分查找，创建一个high和low;
        int len = nums.length;
        int high = len -1;
        int low = 0;
        int mid ;
        //取中间的数
        //目标值不等于中间的值
        //记住要加上 high>low 这个条件
        while (target != nums[mid =(high +low)/2] && high >low ){
            //目标比中间值大，low右移动
            if(target >nums[mid]){
                low = mid +1;
            }else{
                //目标比中间值小，high左移动
                high = mid -1;
            }
        }
        if(target == nums[mid]){
            return mid; 
        }
            return -1;
    }
}

public class MainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
          return new int[0];
        }
    
        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for(int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }
        return output;
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums = stringToIntegerArray(line);
            line = in.readLine();
            int target = Integer.parseInt(line);
            
            int ret = new Solution().search(nums, target);
            
            String out = String.valueOf(ret);
            
            System.out.print(out);
        }
    }
}